package com.vornitologist.ui;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ResourceBundle;

import com.guruyu.hawaii.core.data.TaskData;
import com.guruyu.hawaii.interfaces.HawaiiFactory;
import com.vaadin.addon.touchkit.ui.NavigationView;
import com.vaadin.addon.touchkit.ui.Popover;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.themes.BaseTheme;
import com.vornitologist.VornitologistApplication;


/**
 * A simple detail popup to display information about an observation. Also
 * displays some links to other parts of the applicaction.
 */
public class ObservationDetailPopover extends Popover {

    public ObservationDetailPopover(final TaskData o, final MyUnansignedTask myUnansignedTask) {
        
        setClosable(true);
        setModal(true);

        setWidth("350px");
        setHeight("30%");

        CssLayout detailsLayout = new CssLayout();
        detailsLayout.setSizeFull();
        detailsLayout.setMargin(true);
        detailsLayout.addStyleName("details");
        
        Button button = new Button("Asignarme");
        button.addListener(new ClickListener() {
                        
                        @Override
                        public void buttonClick(ClickEvent event) {
                                HawaiiFactory.getInstance().getIEngineController().getTaskService().claim(o.getId(), (String) getApplication().getUser());
                                myUnansignedTask.populateTable();
                                close();
                        }
                });
        
        detailsLayout.addComponent(button);
        NavigationView navigationView = new NavigationView(detailsLayout);
        Label label = new Label();
        label.setWidth(null);

        setContent(navigationView);

        Button close = new Button(null, new ClickListener() {

            public void buttonClick(ClickEvent event) {
                event.getButton().getWindow().getParent()
                        .removeWindow(event.getButton().getWindow());
            }
        });
        close.setIcon(new ThemeResource("../runo/icons/64/cancel.png"));

        navigationView.setRightComponent(close);

    }
}
